package com.sure.supermarketserver.security.manager.impl;

import com.sure.supermarketserver.common.Utils;
import com.sure.supermarketserver.security.manager.ManagerDto;
import com.sure.supermarketserver.security.manager.ManagerService;
import com.sure.supermarketserver.security.manager.dao.ManagerDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Map;


@Service
@Transactional
public class ManagerServiceImpl implements ManagerService {

    @Resource
    private ManagerDao managerDao;

    @Override
      public Map<String, Object> getManagerList(ManagerDto dto) {
        return Utils.getPage(dto, ()-> managerDao.findManagerList(dto));
    }



    @Override
    public void addManager(ManagerDto dto) {
        managerDao.insertManager(dto);
        managerDao.insertRole(dto);
    }

    @Override
    public void updateManager(ManagerDto dto) {
        managerDao.updateManager(dto);
    }

    @Override
    public void deleteManager(String id) {
        managerDao.deleteManager(id);
    }
}
